package top.soulblack.purchasesale.service.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.system.AnnounceMapper;
import top.soulblack.purchasesale.model.SystemAnnounce;
import top.soulblack.purchasesale.model.VO.AnnounceVO;

import javax.annotation.Resource;
import java.util.List;

/**
 * create by 小川
 */

@Service
public class AnnounceService {

    @Resource
    private AnnounceMapper announceMapper;

    public List<SystemAnnounce> selectAll(){
        return announceMapper.selectAll();
    }


    public void addAnnounce(SystemAnnounce systemAnnounce) {
        announceMapper.addAnnounce(systemAnnounce);
        return;
    }

    public boolean existAnnounce(String name) {
        int num  = announceMapper.existAnnounce(name);
        if (num == 1) {
            return true;
        }
        return false;

    }
    public List<SystemAnnounce> selectForTitle(String title) {
        return announceMapper.selectForTitle(title);
    }

    public boolean deleteAnnounce(int announceId) {
        int num = announceMapper.deleteById(announceId);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean updateAnnounce(SystemAnnounce systemAnnounce) {
        int num = announceMapper.updateByPrimaryKey(systemAnnounce);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public List<AnnounceVO> selectRole(){
        return announceMapper.selectRole();
    }
}
